<template>
  <view class="top">
    <view class="my_top">
      <view class="bigico ico"></view>
      <view class="h1">首页置顶尊享特权</view>
      <view class="h4">首页黄金展示专区，受众率最大，相亲成功率暴增</view>
    </view>
    <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="my_top_cz">
      <view v-for="(item, idx) in ARR" :key="idx" :class="'em ' + item.class" :data-id="item.id" :data-idx="idx"
            :data-price="item.price" @tap="setidFn">
        <view class="h3">置顶{{ item.day }}天</view>

        <view class="b">{{ item.price }}</view>
      </view>
    </view>
    <view class="linebox">
      <view class="line W50"></view>
      <view class="title BAI">置顶显示标准</view>
    </view>
    <view class="my_top_tips">
      <view>
        ● 个人资料必须完整，如头像、生日、身高、昵称等，如果未填请　
        <text class="a" @tap="moddataFn">
          <text class="i ico"></text>
          立即完善
        </text>
      </view>
      <view>● 个人资料资料已通过审核</view>
      <view>● 个人资料状态非隐藏状态</view>
    </view>
    <view class="my_mateshow_btm">
      <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="btn5" @tap="btnFn">
        <block v-if="price > 0">确认支付</block>
        <block v-else>
          <text class="i ico"></text>
          立即置顶
        </block>
      </view>
    </view>
    <view class="blank"></view>
  </view>
</template>

<script>
var t;
var o = require('../../@babel/runtime/helpers/defineProperty');
var a = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
  data() {
    return {
      id: 0,
      color: '',
      rgbcolor: '',
      lovebname: '',
      price: '',
      ARR: ''
    };
  },
  onLoad: function () {
    var that = this;
    app.globalData.get_config('_ZEAI').then(function (t) {
      that.setData({
        color: t.color,
        rgbcolor: a.c16_rgb(t.color),
        lovebname: t.loveb
      });
    });
    app.globalData.chklogin().then(function (a) {
      if (a) {
        t = uni.getStorageSync('COOK_U');
        app.globalData.ajax({
          url: 'my_top.php',
          data: {
            submitok: 'init',
            openid: t.openid
          },
          success: function (t) {
            if (1 == t.flag) {
              if (1 != t.ios_ifpay.flag) {
                uni.getSystemInfo({
                  success: function (a) {
                    if ('ios' == a.platform) {
                      uni.showModal({
                        title: '温馨提示',
                        content: t.ios_ifpay.tips,
                        confirmColor: that.color,
                        cancelText: '返回',
                        confirmText: '联系客服',
                        success: function (t) {
                          if (t.confirm) {
                            uni.redirectTo({
                              url: '/pagesA/about/about?t=contact'
                            });
                          } else {
                            if (t.cancel) {
                              uni.navigateBack();
                            }
                          }
                        }
                      });
                    } else {
                      that.setData({
                        id: t.id,
                        price: t.price,
                        ARR: t.ARR
                      });
                    }
                  }
                });
              } else {
                that.setData({
                  id: t.id,
                  price: t.price,
                  ARR: t.ARR
                });
              }
            } else {
              'noreg' == t.flag
                  ? uni.navigateTo({
                    url: '/pages/login/login'
                  })
                  : uni.showModal({
                    content: t.msg,
                    confirmColor: that.color,
                    confirmText: '朕知道了',
                    showCancel: false,
                    success: function (t) {
                      uni.navigateBack();
                    }
                  });
            }
          }
        });
      } else {
        uni.showModal({
          content: '亲~~~请先登录完善资料再来申请哦',
          confirmColor: that.color,
          confirmText: '朕知道了',
          showCancel: false,
          success: function (t) {
            uni.redirectTo({
              url: '/pages/login/login'
            });
          }
        });
      }
    });
  },
  methods: {
    moddataFn: function () {
      uni.navigateTo({
        url: '/pagesA/reg/reg'
      });
    },

    setidFn: function (t) {
      for (var a, e = t.currentTarget.dataset.id, i = t.currentTarget.dataset.idx, n = t.currentTarget.dataset.price, c = this.ARR, r = 0; r < c.length; r++) {
        if ('ed' == c[r].class) {
          this.setData(o({}, 'ARR[' + r + '].class', ''));
        }
      }
      this.setData((o((a = {}), 'ARR[' + i + '].class', 'ed'), o(a, 'price', n), o(a, 'id', e), a));
    },

    btnFn: function () {
      parseFloat(this.price) > 0
          ? app.globalData.pay({
            data: {
              submitok: 'my_top',
              objid: this.id
            }
          })
          : app.globalData.ajax({
            url: 'my_top.php',
            data: {
              submitok: 'ajax_top_free',
              objid: this.id,
              openid: t.openid
            },
            success: function (t) {
              uni.showToast({
                title: t.msg,
                icon: 'none',
                mask: true,
                duration: 2000
              });
              if (1 == t.flag) {
                setTimeout(function () {
                  uni.reLaunch({
                    url: '/pages/index/index4'
                  });
                }, 2000);
              }
            }
          });
    }
  }
};
</script>
<style lang="scss" scoped>
@import 'top.css';
</style>
